package com.simple.piger.enums;

import com.baomidou.mybatisplus.enums.IEnum;

/**
 * 销售岗位职级
 * @Author  donghj
 * @Date    2018/12/20 15:50
 */
public enum CmsSellerLevel implements IEnum {

    DIRECTOR("总监", 1, null, 10, 100),

    LEADER("团队经理", 2, CmsSellerLevel.DIRECTOR, 20, 90),

    SELLER("业务经理", 3, CmsSellerLevel.LEADER, 70, 70);

    private String desc;
    private Integer level;
    private CmsSellerLevel parentCmsSellerLevel;
    private double defaultRebateRate;//默认三级销售体系时的返利比例
    private double maxRebateRate;//自己售卖时的返利比例

    CmsSellerLevel(final String desc, final Integer level, final CmsSellerLevel parentCmsSellerLevel, final double defaultRebateRate, final double maxRebateRate) {
        this.desc = desc;
        this.level = level;
        this.parentCmsSellerLevel = parentCmsSellerLevel;
        this.defaultRebateRate = defaultRebateRate;
        this.maxRebateRate = maxRebateRate;
    }

    @Override
    public String getValue() {
        return this.name();
    }

    public String getDesc() {
        return this.desc;
    }

    public Integer getLevel() {
        return this.level;
    }

    public CmsSellerLevel getParentCmsSellerLevel() {
        return this.parentCmsSellerLevel;
    }

    public double getDefaultRebateRate() {
        return this.defaultRebateRate;
    }

    public double getMaxRebateRate() {
        return this.maxRebateRate;
    }

    public static CmsSellerLevel getCmsSellerLevelByValue(String value) {
        if (value == null) {
            return null;
        }
        for (CmsSellerLevel cmsSellerLevel : CmsSellerLevel.values()) {
            if (cmsSellerLevel.getValue().equals(value)) {
                return cmsSellerLevel;
            }
        }
        return null;
    }
}